/**
 * Ingenius-Group S.A.S
 *
 * Project: SAU
 * File: Document.java
 * Date: 13/11/2010
 */

package com.ingenius.sau.shared.model.instruments;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.ingenius.sau.shared.model.core.BaseBean;

/**
 * Class <strong>Document</strong>
 * 
 * @author Jesus David
 * @version 0.1
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Document implements BaseBean, Instrument {

	// DATA
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;

	@Persistent
	private String name;

	@Persistent
	private String description;

	@Persistent
	private String attachmentUrl;

	@Persistent
	private String attachmentName;

	@Persistent
	private String processId;

	// CONSTRUCTORS

	public Document() {
	}

	public Document(String id) {
		this.id = id;
	}

	// METHODS

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAttachmentUrl() {
		return attachmentUrl;
	}

	public void setAttachmentUrl(String url) {
		this.attachmentUrl = url;
	}

	public String getAttachmentName() {
		return attachmentName;
	}

	public void setAttachmentName(String name) {
		this.attachmentName = name;
	}

	public String getProcessId() {
		return processId;
	}

	public void setProcessId(String processId) {
		this.processId = processId;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Document) {
			return ((Document) obj).getId().equals(id);
		}
		return false;
	}

	@Override
	public String toString() {
		return name + " - " + description;
	}

	public Document toDTO() {
		return this;
	}

}
